package com.example.myapp;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class zhouqi extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_zhouqi);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

//        接收参数
        Intent intent = getIntent();
        if(intent != null) {
            String name = intent.getStringExtra("name");
            int id = intent.getIntExtra("id", 0);
            Log.d("zhouqiMessage", String.format("name: %s id: %d", name, id));
        }

        Button backBtn = findViewById(R.id.backBtn);
        backBtn.setOnClickListener(v -> {
            Intent returnIntent = new Intent();
            returnIntent.putExtra("result", "返回的数据");
            setResult(200, returnIntent);
            finish();
        });

//        初始化
        Log.d("zhouqiMessage", "onCreate----------------->>>>>>>>>");
    }

    @Override
    protected void onStart() {
        super.onStart();
//        加载出页面
        Log.d("zhouqiMessage", "onStart----------------->>>>>>>>>");
    }

    @Override
    protected void onResume() {
        super.onResume();
//        此时可以和用户互动
        Log.d("zhouqiMessage", "onResume----------------->>>>>>>>>");
    }

    @Override
    protected void onPause() {
        super.onPause();
//        界面暂停
        Log.d("zhouqiMessage", "onPause----------------->>>>>>>>>");
    }

    @Override
    protected void onStop() {
        super.onStop();
//      用户不在屏幕上
        Log.d("zhouqiMessage", "onStop----------------->>>>>>>>>");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        销毁
        Log.d("zhouqiMessage", "onDestroy----------------->>>>>>>>>");
    }
}